package cn.kkcxy.blog.system.mapper.article;

import cn.kkcxy.blog.core.entity.article.ArticleCategory;
import cn.kkcxy.blog.core.vo.client.archive.category.ClientCommonArticleCategoryVO;
import cn.kkcxy.blog.core.vo.client.archive.category.ClientFirstLevelArticleCategoryVO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author kk
 * @description 针对表【article_category】的数据库操作Mapper
 * @createDate 2024-09-18 00:25:54
 * @Entity cn.kkcxy.blog.core.entity.article.ArticleCategory
 */
public interface ArticleCategoryMapper extends BaseMapper<ArticleCategory> {

    /**
     * 获取文章分类列表数据
     */
    List<ClientFirstLevelArticleCategoryVO> getArticleCategoryListData();

    /**
     * 根据分类名称查询分类ID
     */
    @Select("select id from article_category where category_name = #{categoryName} and deleted = #{deleted}")
    Long getCategoryIdByCategoryName(@Param("categoryName") String categoryName, @Param("deleted") Integer deleted);

    /**
     * 根据一级分类ID获取该分类下所有子分类ID
     */
    List<Long> getSecondLevelCategoryIdsByPrimaryCategoryId(Long primaryCategoryId);

    /**
     * 根据二级分类名称获取该分类ID
     */
    List<Long> getSecondLevelCategoryIdsBySecondLevelCategoryName(List<String> secondLevelCategoryName);

    /**
     * 根据分类id查询分类名称
     */
    @Select("select category_name from article_category where id = #{categoryId} and deleted = #{deleted};")
    String getCategoryNameByCategoryId(@Param("categoryId") Long categoryId, @Param("deleted") Integer deleted);

    /**
     * 获取文章分类数据
     */
    List<ClientCommonArticleCategoryVO> getArticleCategories
    (@Param("parentId") Long parentId, @Param("categoryType") Integer categoryType, @Param("deleted") Integer deleted);

    /**
     * 根据分类id获取文章分类下文章数
     */
    List<ClientCommonArticleCategoryVO> getArticleCategoryCountListByCategoryIds(List<Long> ids);

    /**
     * 获得分类总数
     */
    @Select("select count(*) from article_category where deleted = 0")
    Integer getCategoryCount();
}




